package model

import (
	"gddgame.cc/galaxy/common/dsl/db"
	"gddgame.cc/galaxy/common/dsl/game"
	"gddgame.cc/galaxy/common/dsl/game/user"
)

var (
	MapModel     *db.Table
	MapNoModel   *db.Table
	MapNodeModel *db.Table

	DefineBuildModel      *db.Table
	DefineBuildLevelModel *db.Table
	DefineUnitModel       *db.Table
	DefineUnitLevelModel  *db.Table
	DefineNodeModel       *db.Table
	DefineItemModel       *db.Table

	UserModel      *db.Table
	UserMapModel   *db.Table
	UserEquipModel *db.Table
	UserPropModel  *db.Table
	UserUnitModel  *db.Table

	SettingMessageModel      *db.Table
	SettingDirectModel       *db.Table
	SettingOperationModel    *db.Table
	SettingEquipModel        *db.Table
	SettingEquipLevelModel   *db.Table
	SettingPowerModel        *db.Table
	SettingPowerLevelModel   *db.Table
	SettingPropModel         *db.Table
	SettingScienceModel      *db.Table
	SettingScienceLevelModel *db.Table
	SettingShopPropModel     *db.Table

	Provider = game.ModuleProvider{
		Name:    "breeder",
		Depends: []string{"ad", "config", "group", "stat", "base", "user", "attr", "skill", "language", "sync"},
		OnInit: func(env *game.Environment) error {
			var err error
			if MapModel, err = env.RegisterModel(MapName, &Map{}); err != nil {
				return err
			}
			if MapNoModel, err = env.RegisterModel(MapNoName, &MapNo{}); err != nil {
				return err
			}
			if MapNodeModel, err = env.RegisterModel(MapNodeName, &MapNode{}); err != nil {
				return err
			}
			if DefineBuildModel, err = env.RegisterModel(DefineBuildName, &DefineBuild{}); err != nil {
				return err
			}
			if DefineBuildLevelModel, err = env.RegisterModel(DefineBuildLevelName, &DefineBuildLevel{}); err != nil {
				return err
			}
			if DefineUnitModel, err = env.RegisterModel(DefineUnitName, &DefineUnit{}); err != nil {
				return err
			}
			if DefineUnitLevelModel, err = env.RegisterModel(DefineUnitLevelName, &DefineUnitLevel{}); err != nil {
				return err
			}
			if DefineNodeModel, err = env.RegisterModel(DefineNodeName, &DefineNode{}); err != nil {
				return err
			}
			if DefineItemModel, err = env.RegisterModel(DefineItemName, &DefineItem{}); err != nil {
				return err
			}
			if UserModel, err = env.RegisterModel(user.UserName, DefaultUser); err != nil {
				return err
			}
			if UserMapModel, err = env.RegisterModel(UserMapName, &UserMap{}); err != nil {
				return err
			}
			if UserEquipModel, err = env.RegisterModel(UserEquipName, &UserEquip{}); err != nil {
				return err
			}
			if UserPropModel, err = env.RegisterModel(UserPropName, &UserProp{}); err != nil {
				return err
			}
			if UserUnitModel, err = env.RegisterModel(UserUnitName, &UserUnit{}); err != nil {
				return err
			}
			if SettingMessageModel, err = env.RegisterModel(SettingMessageName, &SettingMessage{}); err != nil {
				return err
			}
			if SettingDirectModel, err = env.RegisterModel(SettingDirectName, &SettingDirect{}); err != nil {
				return err
			} else {
				SettingDirectModel.Link = "link"
				SettingDirectModel.Linked = "linked"
			}
			if SettingOperationModel, err = env.RegisterModel(SettingOperationName, &SettingOperation{}); err != nil {
				return err
			}
			if SettingEquipModel, err = env.RegisterModel(SettingEquipName, &SettingEquip{}); err != nil {
				return err
			}
			if SettingEquipLevelModel, err = env.RegisterModel(SettingEquipLevelName, &SettingEquipLevel{}); err != nil {
				return err
			} else {
				SettingEquipLevelModel.Link = "link"
			}
			if SettingPowerModel, err = env.RegisterModel(SettingPowerName, &SettingPower{}); err != nil {
				return err
			}
			if SettingPowerLevelModel, err = env.RegisterModel(SettingPowerLevelName, &SettingPowerLevel{}); err != nil {
				return err
			} else {
				SettingPowerLevelModel.Link = "link"
			}
			if SettingPropModel, err = env.RegisterModel(SettingPropName, &SettingProp{}); err != nil {
				return err
			} else {
				SettingPropModel.Link = "link"
			}
			if SettingShopPropModel, err = env.RegisterModel(SettingShopPropName, &SettingShopProp{}); err != nil {
				return err
			}
			if SettingScienceModel, err = env.RegisterModel(SettingScienceName, &SettingScience{}); err != nil {
				return err
			}
			if SettingScienceLevelModel, err = env.RegisterModel(SettingScienceLevelName, &SettingScienceLevel{}); err != nil {
				return err
			} else {
				SettingScienceLevelModel.Link = "link"
			}
			return nil
		},
	}
)
